package com.rrjjg.app.core.interceptor;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * ----------------------------------------------------------------------------- <br>
 * 功能 :  <br>
 * <p>
 * 授权 : (C) Copyright (c) 2022 <br>
 * ----------------------------------------------------------------------------- <br>
 * 作者 : Vayne <br>
 * 时间 : 2022/8/11 12:47 <br>
 */
public class SpringMvcConfig implements WebMvcConfigurer {

    LoginInterceptor loginInterceptor;

    SignInterceptor signInterceptor;

    public SpringMvcConfig(LoginInterceptor loginInterceptor) {
       this(loginInterceptor,null);
    }

    public SpringMvcConfig(LoginInterceptor loginInterceptor, SignInterceptor signInterceptor) {
        this.loginInterceptor = loginInterceptor;
        this.signInterceptor = signInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/rrjjg/**");
        if (signInterceptor != null) {
            registry.addInterceptor(signInterceptor).addPathPatterns("/rrjjg/**")
                    .excludePathPatterns(signInterceptor.getExclude());
        }
    }

}
